#include<iostream>
using namespace std;
#include<vector>
#include<algorithm>

vector<vector<int>> generate(int numRows) {
   vector<vector<int>> s(numRows);
   for (size_t i = 0; i < s.size(); ++i)
   {
       s[i].resize(numRows,1);
   }
   for (size_t i = 2; i < s.size(); ++i)
   {
       for (size_t j = 1; j <= i - 1; ++j)
       {
           s[i][j] = s[i - 1][j - 1] + s[i - 1][j];
       }
   }

   return s;
}

int removeDuplicates(vector<int>& nums) {
   int ret = nums.size();
   if (ret == 0)
   {
       return 0;
   }
   int fast = 1;
    int low = 0;
    int count = 0;
   while (fast < nums.size())
   {
       if (  nums[fast] == nums[ low ])
       {
           nums.erase(nums.begin() + fast );
           count++;
       }
       else
       {
           fast++;
           low++;
       }
      
   }

   return count;

}

int singleNumber(vector<int>& nums) {
   int i = 0;
   sort(nums.begin(), nums.end());
   while (i < nums.size())
   {

       if (i + 1 < nums.size() && nums[i] == nums[i + 1])
       {
           i += 3;
       }
       else
       {
           return nums[i];
       }
   }
  // return nums[i];
}


vector<int> SingleNumber(vector<int>& nums) {
   const int n = nums.size();
   if (n == 2)
       return nums;

   vector<int> sss(2);

   sort(nums.begin(), nums.end());
   vector<int> array(n);
   int s = 0,i = 0,j = 0;
   for (; i < n ; )
   {   
       if ((i + 1) == n)
       {
           sss[s] = nums[i];
           array[j] = 1;
           break;
       }
       if (nums[i] != nums[i + 1])
       {
           sss[s++] = nums[i];
           array[j++] = 1;
           i++;
       }
       else
       {
           array[j++] = 2;
           i += 2;
       }
   }
   return sss;
}





int main()
{
   
   //generate(5);
   //vector<int> vv{ 1,1,2,2,3,3,3,4,4,4,4 };
  // removeDuplicates(vv);
  /* vector<int> vv{ 0,1,0,1,0,1,99 };
   singleNumber(vv);*/
   vector<int> vv{ 0,0,1,2 };
   vector<int>ret = SingleNumber(vv);
	return 0;
}